Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/deseng439: Created Timline Widget and merged with Content from Main #2347

Merged
merged 11 commits into from
Jan 9, 2024

Conversation

jareth-whitney
Copy link
Contributor

  • Created Timeline Widget
  • Linted met-api and met-web
  • Merged content with content from main branch
    • Apologies for merged content from main branch, this was the only way to do it due to branch changes while I was working on this project

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the met-public license (Apache 2.0).

NatSquared and others added 10 commits October 18, 2023 16:06
Add a change log to allow developers to log any changes they make to the project.
* Feature: update sample .env files

* Remove old production .env file

* Update DEVELOPMENT.md to reflect project state

* Update CHANGELOG.md before PR

* Link JIRA ticket # on relevant changes
* Made slug url case insensitive , Fixed bug with wrong query join for submission (#2321)

* Made slug url case insensitive ,
Fixed bug with wrong query join for submission

* removed a couple of if statements

* CSV export made working for multipage wizard surveys (#2322)

---------

Co-authored-by: saravanpa-aot <[email protected]>
* bugfix/deseng413: Upgraded BC-Sans font to newest version.

* bugfix/deseng413: Small update to changelog for clarification.
* feature/deseng415: Added recording of date with feedback submission and displaying the data on admin side.

* feature/deseng415: Fixed feedback schema, removed yup import, fixed change log date.
* bugfix/deseng429: Removed outdated service class.

* bugfix/deseng429: Changed version and changelog to match deployments to gdx-main.
CHANGELOG.MD Show resolved Hide resolved
{
'id': 8,
'name': 'CAC Form',
'description': 'Add a CAC Form to your project',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imagine this example text should be changed? CAC forms are unrelated to timelines, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, in met-web, for the widget type ENUM, value 8 is reserved for CAC forms. Timeline is 9. When I looked in the DB, CAC Form was missing as a widget type, so I added it as number 8 and added Timeline as number 9. I thought it would be better to leave that path open, rather than remove all instances of CAC Form.

Copy link
Collaborator

@Baelx Baelx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work Jareth! Just a few small things to update if you could:

  • Clean up confusing comments or those that aren't adding anything
  • Correct CORS preflight list of request types in widget_timeline resource
  • Use strict equality checks in styled components

met-api/src/met_api/resources/widget_timeline.py Outdated Show resolved Hide resolved
return str(err), err.status_code


@cors_preflight('PATCH')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not your issue but I don't think the API ever caches the preflight response in the client, right? We should implement that at some point - I'll create a ticket. Each options call is a round-trip request we could be saving.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK sounds good, so I think there's no action items for this PR related to this comment.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct! No action item needed for the PR but I was wondering if you knew if the preflight responses were ever cached.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I don't know much about the preflight cache. It sounds like you already know more than me!

met-api/src/met_api/schemas/widget_timeline.py Outdated Show resolved Hide resolved
met-api/src/met_api/schemas/widget_timeline.py Outdated Show resolved Hide resolved
met-api/src/met_api/schemas/widget_timeline.py Outdated Show resolved Hide resolved
return TimelineEventModel.update_timeline_event(timeline_event.id, event_data)

@staticmethod
def _create_timeline_event_model(timeline_id, event_data: dict):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if we need to have a separate method to build up the model data but if you want to keep it as a "private" class method then you could preface the name with 2 underscores as is convention.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at all of the other services, it seems like everything uses the single underscore convention. I'm not disagreeing that it should be updated, but perhaps that should be a separate ticket where someone changes all instances at once.

events = db.relationship(TimelineEvent, backref='widget_timeline', lazy=True)

@classmethod
def get_timeline(cls, timeline_id) -> list[WidgetTimeline]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be a pattern throughout the app of models only containing some CRUD methods. In looking through the models, some have all 4 methods (GET, PATCH, POST, DELETE) and sometimes half of those are handled in the Service class (including the corresponding DB operations).

I don't understand why that pattern is in place but I feel all CRUD operations should live inside the models. Was there a reason that you didn't include the POST operation besides just copying from another file? I remember you mentioned the DELETE operation is handled by the base Widget class, so I understand that.

I know we have pressure on us to get features done but I also feel the PO would understand us taking more time to make things more consistent and better in the code base.

Copy link
Contributor Author

@jareth-whitney jareth-whitney Jan 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So anything that touches the db is defined in the model. Then the service just uses those methods from the model to do stuff. I was confused at first too, and so was Nat, but after looking at the logic, I now understand it. Sometimes a service method doesn't need to call a model method that touches the db, so nothing is defined in the model.

Copy link

sonarqubecloud bot commented Jan 9, 2024

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

7 New issues
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@codecov-commenter
Copy link

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (f7e3ac7) 68.56% compared to head (c1b953c) 68.93%.
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2347      +/-   ##
==========================================
+ Coverage   68.56%   68.93%   +0.37%     
==========================================
  Files         472      509      +37     
  Lines       15593    15989     +396     
  Branches     1193     1168      -25     
==========================================
+ Hits        10691    11022     +331     
- Misses       4693     4758      +65     
  Partials      209      209              
Flag Coverage Δ
analyticsapi 79.37% <71.42%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
met-api/src/met_api/__init__.py 97.18% <ø> (-0.12%) ⬇️
met-api/src/met_api/config.py 100.00% <ø> (+3.22%) ⬆️
met-api/src/met_api/models/__init__.py 100.00% <ø> (ø)
met-api/src/met_api/models/base_model.py 92.30% <ø> (+0.92%) ⬆️
met-api/src/met_api/models/engagement.py 76.79% <ø> (+1.27%) ⬆️
met-api/src/met_api/models/engagement_metadata.py 61.90% <ø> (+0.36%) ⬆️
met-api/src/met_api/models/engagement_slug.py 100.00% <100.00%> (ø)
met-api/src/met_api/models/feedback.py 90.74% <ø> (ø)
met-api/src/met_api/resources/__init__.py 100.00% <ø> (ø)
met-api/src/met_api/resources/engagement.py 83.33% <ø> (ø)
... and 46 more

... and 36 files with indirect coverage changes

Copy link
Collaborator

@Baelx Baelx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes!

@jareth-whitney jareth-whitney merged commit f2a1f8e into main Jan 9, 2024
14 of 19 checks passed
@jareth-whitney jareth-whitney deleted the feature/deseng439 branch January 9, 2024 08:12
NatSquared added a commit that referenced this pull request Jan 19, 2024
…m Main (#2347)

* Add initial version of change log (#2318)

Add a change log to allow developers to log any changes they make to the project.

* Feature/update sample env files (#2320)

* Feature: update sample .env files

* Remove old production .env file

* Update DEVELOPMENT.md to reflect project state

* Update CHANGELOG.md before PR

* Link JIRA ticket # on relevant changes

* Bring bugfixes from main into gdx-dev (#2328)

* Made slug url case insensitive , Fixed bug with wrong query join for submission (#2321)

* Made slug url case insensitive ,
Fixed bug with wrong query join for submission

* removed a couple of if statements

* CSV export made working for multipage wizard surveys (#2322)

---------

Co-authored-by: saravanpa-aot <[email protected]>

* bugfix/deseng421: Changed engagement links so that they open in the same window/tab as opposed to a new one. (#2329)

* Bugfix/deseng413 (#2330)

* bugfix/deseng413: Upgraded BC-Sans font to newest version.

* bugfix/deseng413: Small update to changelog for clarification.

* Feature/deseng415 (#2334)

* feature/deseng415: Added recording of date with feedback submission and displaying the data on admin side.

* feature/deseng415: Fixed feedback schema, removed yup import, fixed change log date.

* bugfix/deseng429: Removed outdated service class. (#2337)

* bugfix/deseng429: Removed outdated service class.

* bugfix/deseng429: Changed version and changelog to match deployments to gdx-main.

* feature/deseng439: Finished the Timeline Widget and linted.

* feature/deseng439: Updated changelog before merge.

* feature/deseng439: Made revisions as per Alex and added sorting to React components.

---------

Co-authored-by: Nat² <[email protected]>
Co-authored-by: saravanpa-aot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants